<?php
require_once 'glob.php';
if($_REQUEST['page']==""||$_REQUEST['page']==null)
{
	$page=1;
}else {
	$page=$_REQUEST['page'];
}
switch ($_REQUEST['action']) {
	case 'list':
		get_list('sn_servermail', array( id,smtpserver,smtpmail,smtpuser,mailtype),'maillist','servermail_list.htm','fypage',$page,'where isdel="N"','?action=list&');


		break;

	case 'add':
		//初始化编辑器{$editor1}
		create_html_editor($editor,'fm_mailcontent');
		$xueniao->display('servermail_info.htm');
		break;
	case 'insert':
		if($_REQUEST['fm_smtpserver']!=="")
		{
			$post=array(
			smtpserver=>$_REQUEST['fm_smtpserver'],
			smtpmail=>$_REQUEST['fm_smtpmail'],
			smtpuser=>$_REQUEST['fm_smtpuser'],
			smtppass=>$_REQUEST['fm_smtppass'],
			mailtype=>$_REQUEST['fm_mailtype'],
			mailtitle=>$_REQUEST['fm_mailtitle'],
			mailcontent=>$_REQUEST['fm_mailcontent']
			);
			$res=$db->insert('sn_servermail',$post);
			if($res==true){
				sys_msg('服务邮件添加成功',0);
			}
		}
		break;
	case 'edit':
		if($_REQUEST['id']=="" || $_REQUEST['id']==null)
		{
			sys_msg('未指定信息分类,无法修改', 1);
			exit();
		}else {
			$fm_id=$_REQUEST['id'];
		}
		create_html_editor($editor,'fm_mailcontent',getinfo('sn_servermail','id',$fm_id,'mailcontent'));

		get_info('sn_servermail', 'id,smtpserver,smtpmail,smtpuser,smtppass,mailtype,mailtitle,mailcontent', 'maillistinfo', 'servermail_info.htm','id = '.$fm_id);
		break;
	case 'update':
		if($_REQUEST['id']=="" || $_REQUEST['id']==null)
		{
			sys_msg('未指定服务邮件,无法修改', 1);
			exit();
		}else {
			$fm_id=$_REQUEST['id'];
		}
		$post=array(
		id=>$fm_id,
		//要更改的id
		smtpserver=>$_REQUEST['fm_smtpserver'],
		smtpmail=>$_REQUEST['fm_smtpmail'],
		smtpuser=>$_REQUEST['fm_smtpuser'],
		smtppass=>$_REQUEST['fm_smtppass'],
		mailtype=>$_REQUEST['fm_mailtype'],
		mailtitle=>$_REQUEST['fm_mailtitle'],
		mailcontent=>$_REQUEST['fm_mailcontent']
		);
		$res=$db->update('sn_servermail',$post,id);

		if($res==true){
			sys_msg('服务邮件修改成功！',0);
		}

		break;
	default:
		get_list('sn_servermail', array( id,smtpserver,smtpmail,smtpuser,mailtype),'maillist','servermail_list.htm','fypage',$page,'where isdel="N"','?action=list&');
		break;
}